Skip to content

chore: add MustSafecast helper for type conversions#2730

Open
ivanauth wants to merge 1 commit intoauthzed:mainfrom
ivanauth:fix/issue-2714-implement-mustsafecast
Open

chore: add MustSafecast helper for type conversions#2730
ivanauth wants to merge 1 commit intoauthzed:mainfrom
ivanauth:fix/issue-2714-implement-mustsafecast

Conversation

@ivanauth
Copy link
Contributor

Summary

Add a MustSafecast helper function to the spiceerrors package that panics on cast failure, complementing the existing Safecast function.

Fixes #2714

Changes

  • Add MustSafecast[I, O] function in pkg/spiceerrors/safecast.go
  • Panics with descriptive error when cast fails (for use in cases where failure indicates a programming error)
  • Update .gitignore to properly ignore __pycache__/ directories

@ivanauth ivanauth requested a review from a team as a code owner November 25, 2025 22:54
@github-actions github-actions bot added area/schema Affects the Schema Language area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Nov 25, 2025
@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.53%. Comparing base (c16c1c3) to head (8a3ff9f).

❌ Your project check has failed because the head coverage (74.53%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2730      +/-   ##
==========================================
+ Coverage   74.50%   74.53%   +0.03%     
==========================================
  Files         494      494              
  Lines       60626    60613      -13     
==========================================
+ Hits        45166    45174       +8     
+ Misses      12298    12284      -14     
+ Partials     3162     3155       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ivanauth
Copy link
Contributor Author

The failing CRDB 25.2.0 consistency test doesn't look related to the MustSafecast changes. The error is a database timeout:

ERROR: query execution canceled (SQLSTATE 57014)

CRDB 25.3.0 passes, as do all other datastores. Seems like a CRDB 25.2.0-specific issue.

@ivanauth ivanauth force-pushed the fix/issue-2714-implement-mustsafecast branch from a177ea2 to e8d27fb Compare January 8, 2026 22:00
@miparnisari miparnisari force-pushed the fix/issue-2714-implement-mustsafecast branch from 8961c43 to a01d191 Compare February 26, 2026 12:59
Copy link
Contributor

@miparnisari miparnisari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feat: add MustSafecast helper for type conversions

can you update this to chore:...? also you need to amend the PR title

and since this is a chore that doesn't impact end users, can you add the Skip-Changelog label to the PR?

@ivanauth ivanauth changed the title Add MustSafecast helper for type conversions chore: add MustSafecast helper for type conversions Feb 26, 2026
@ivanauth ivanauth force-pushed the fix/issue-2714-implement-mustsafecast branch from a01d191 to d677de5 Compare February 26, 2026 15:53
@ivanauth
Copy link
Contributor Author

done!

@ivanauth ivanauth force-pushed the fix/issue-2714-implement-mustsafecast branch from 5f150d1 to c997ec6 Compare March 5, 2026 21:33
@miparnisari miparnisari enabled auto-merge (squash) March 6, 2026 23:52
Adds MustSafecast function following the MustBugf pattern:
- Panics in tests when conversion fails
- Returns zero value in production with warning log
- Replaces manual safecast error handling across codebase

Closes authzed#2714
@miparnisari miparnisari force-pushed the fix/issue-2714-implement-mustsafecast branch from c997ec6 to 8a3ff9f Compare March 6, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/datastore Affects the storage system area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) Skip-Changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement MustSafecast function in spiceerrors and use across codebase

2 participants